package gogogo.liwushuo.fragment.HotFragment;

import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.gc.flashview.FlashView;
import com.google.gson.Gson;
import com.squareup.picasso.Picasso;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import gogogo.liwushuo.R;
import gogogo.liwushuo.bean.HotFragmentBean;
import gogogo.liwushuo.constant.Resource;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;

/**
 * author: John
 * time: 2016/7/22
 * overview:
 * usage:
 */
public class GoodsFragment extends Fragment {
//    @InjectView(R.id.hot_goods_flashview)
//    FlashView hotGoodsFlashview;
//    @InjectView(R.id.hot_detail_title)
//    TextView hotDetailTitle;
//    @InjectView(R.id.hot_detail_price)
//    TextView hotDetailPrice;
//    @InjectView(R.id.hot_detail_desc)
//    TextView hotDetailDesc;
//    @InjectView(R.id.hot_detail_image)
//    ImageView hotDetailImage;
//    private List<HotFragmentBean.DataBean.ItemsBean> mDatas;
//    @Override
//    public void onCreate(@Nullable Bundle savedInstanceState) {
//        super.onCreate(savedInstanceState);
//        mDatas=new ArrayList<>();
//    }
//
//    @Nullable
//    @Override
//    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//        View view = inflater.inflate(R.layout.fragment_hot_goods, container, false);
//        ButterKnife.inject(this, view);
//        return view;
//    }
//
//    @Override
//    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
//        super.onViewCreated(view, savedInstanceState);
//        initView(view);
//        initData();
//    }
//
//    private void initView(View view) {
////        hotGoodsFlashview= (FlashView) view.findViewById(R.id.hot_goods_flashview);
////        hotDetailTitle = (TextView) view.findViewById(R.id.hot_detail_title);
////        hotDetailPrice= (TextView) view.findViewById(R.id.hot_detail_price);
////        hotDetailDesc= (TextView) view.findViewById(R.id.hot_detail_desc);
////        hotDetailImage= (ImageView) view.findViewById(R.id.hot_detail_image);
//    }
//
//    private void setData(HotFragmentBean.DataBean.ItemsBean bean) {
//        Log.i("123",bean+"");
//        List<String> webp_urls = bean.getData().getWebp_urls();
//        Log.i("123",webp_urls.size()+"");
////        hotGoodsFlashview.setImageUris(webp_urls);
////        hotDetailTitle.setText(bean.getData().getName());
////        String text = "￥" + bean.getData().getPrice();
////        hotDetailPrice.setText(text);
////        hotDetailDesc.setText(bean.getData().getDescription());
//    }
//    Handler mHandler=new Handler();
//    private void initData() {
//        OkHttpClient okHttpClient = new OkHttpClient();
//        final Request request = new Request.Builder()
//                .url(Resource.URL_SELECT)
//                .build();
//        Call call = okHttpClient.newCall(request);
//        call.enqueue(new Callback() {
//            @Override
//            public void onFailure(Call call, IOException e) {
//
//            }
//
//            @Override
//            public void onResponse(Call call, Response response) throws IOException {
//                final String result = response.body().string();
//                System.out.println(request);
//                mHandler.post(new Runnable() {
//                    @Override
//                    public void run() {
//                        HotFragmentBean.DataBean.ItemsBean bean = new Gson().fromJson(result, HotFragmentBean.DataBean.ItemsBean.class);
//                        setData(bean);
//                    }
//                });
//            }
//        });
//    }
//    @Override
//    public void onDestroyView() {
//        super.onDestroyView();
//        ButterKnife.reset(this);
//    }
}
